<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019-03-28
 * Time: 下午 4:39
 */
namespace Model;
class ActivityMemberMod extends Mod
{
	public function __construct()
	{
		$this->_table = 'kuyuan_vbz_activity_member';
	}

    /**
     * 获取活动的人数
     */
	public function activityMemberNumber($_activity_id,$_timestamp)
    {
        $_sql = "SELECT 
						COUNT('id') as count 
					FROM
						".tablename($this->_table)."	
					WHERE
					    activity_id = :activity_id
					AND
					    time > :times
					AND
					    time < :end_times
				";
        $_bind = array('activity_id'=>$_activity_id,'times'=>$_timestamp,'end_times'=>$_timestamp+86400);
        return pdo_fetchcolumn($_sql,$_bind);
    }

    /**
     * 获取活动指定日期真正参与的人数
     */
	public function activityMemberJoinNumber($_activity_id,$_timestamp)
    {
        $_sql = "SELECT 
						COUNT(distinct B.uid) as count 
					FROM
						".tablename($this->_table)." as A
					LEFT JOIN
					    ".tablename('kuyuan_vbz_activity_member_treasure')." as B
					ON
					    A.uid = B.uid
					WHERE
					    A.activity_id = :activity_id
					AND
					    A.time > :times
					AND
					    A.time < :end_times
				";
        $_bind = array('activity_id'=>$_activity_id,'times'=>$_timestamp,'end_times'=>$_timestamp+86400);
        return pdo_fetchcolumn($_sql,$_bind);
    }

}